# -*- coding: utf-8 -*-
'''
Created on 2011-10-10

@author: deadblue
'''

from google.appengine.ext.webapp import template
import time

def get_status_name(code):
    code = code % 3
    names = ['正常', '禁用', '无效']
    return names[code]

def format_timestamp(ts):
    if ts is None:
        return ''
    # 转换为GMT+8时区
    tm = time.gmtime(ts + 28800)
    return time.strftime('%Y-%m-%d %H:%M:%S', tm)

register = template.create_template_register()
register.filter('status_name', get_status_name)
register.filter('gmt8_time', format_timestamp)